﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Security;
using System.Web.UI.WebControls;

public partial class Admin_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string user = txtUser.Text.Trim();
        string pass = txtPassword.Text.Trim();

        login(user, pass);
    }
    private void login(string _user, string _password)
    {

        BookStoreDataContext bs = new BookStoreDataContext();
        bool? a = true;

        if (bs.sp_isUserExist(_user, _password, ref a) > 0)
        {
            if (_user == "admin") { }
            FormsAuthentication.SetAuthCookie(txtUser.Text.Trim(), true);
            Session["login"] = (txtUser.Text.Trim());
            Response.Redirect("default.aspx");
        }
        else
        {

            pnlloginMessage.Visible = true;
        }
    }
}